package com.xuchang.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;



/**
 * 审核状态枚举
 *
 */
@Getter
@AllArgsConstructor
public enum StatusEnum {
    PENNDING(0, "待审核"),


    PASS(1, "审核通过"),

    REJECT(2,"拒绝"),

    SUCCESS(3,"提现成功"),

    UNKNOWN(-1, "未知");

    private final Integer value;

    @JsonFormat
    private final String description;

    public static StatusEnum convert(Integer value) {
        return Stream.of(values())
                .filter(bean -> bean.value.equals(value))
                .findAny()
                .orElse(UNKNOWN);
    }

    public static StatusEnum convert(String description) {
        return Stream.of(values())
                .filter(bean -> bean.description.equals(description))
                .findAny()
                .orElse(UNKNOWN);
    }
}
